home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
283
< prev
next >
Wrap
Text File
|
1996-08-06
|
2KB
|
64 lines
Path: swidir.switch.ch!epflnews!Thomas.Wolf
From: Thomas.Wolf@di.epfl.ch (Thomas Wolf)
Newsgroups: comp.std.c
Subject: Re: Are macros expanded within unused macro arguments?
Date: 2 Feb 1996 08:36:38 GMT
Organization: Ecole Polytechnique FΘdΘrale de Lausanne
Sender: wolf@lglsun5.epfl.ch (Thomas Wolf)
Message-ID: <4esiem$bbr@info.epfl.ch>
References: <DM3MC3.Atv@scr.siemens.com> <TANMOY.96Feb1102025@qcd.lanl.gov> <4es8rp$98n@usenet.pa.dec.com>
NNTP-Posting-Host: lglsun5.epfl.ch
In article <4es8rp$98n@usenet.pa.dec.com>, diamond@tko.dec.com (Norman Diamond) writes:
:> In article <TANMOY.96Feb1102025@qcd.lanl.gov>, tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes:
:> >In article <DM3MC3.Atv@scr.siemens.com> mlg@scr.siemens.com (Michael
:> >Greenberg) writes:
:> >>Is the following program legal?
:> >>#define foo(unused)
:> >>#define bar(x,y)
:> >>foo(bar(1))
:>
:> >I read it as being legal.
:>
:> Mr. Bhattacharya, I am shocked.
:>
[Snip]
Mr. Diamond, why are you shocked? Macro 'bar' is not invoked. Read 6.8.3.1
again: we do
- identify the parameters
Ok, 'foo' has one parameter, "bar(1)".
- replace occurrences of the formal parameter ('unused') in the
replacement list by the corresponding argument after macro re-
placement within this argument.
Well, 'foo's replacement list is empty, so this never happens.
In other words, since there's no 'unused' in the replacement
list, we'll never try to substitute it by the argument "bar(1)",
thus we'll never try to perform macro replacement on "bar(1)"
and therefore 'bar' is not invoked.
Your quote from 6.8.3 (3.8.3. in ANSI Classic) does not apply:
:> lines 14 to 15: "The number of arguments in an INVOCATION of a
:> function-like macro shall agree with the number of parameters in
:> the macro definition, and [...]"
(Emphasis added, TW)
Above quote applies only to *invocations*, but since 'bar' is not invoked,
it's irrelevant in this example.
Regards,
Thomas
----------------------------------------------------------------------
Swiss Federal Institute of Technology | Thomas Wolf
Software Engineering Laboratory | EPFL-DI-LGL
Thomas Wolf (TW) | CH-1015 Lausanne (Suisse)
E-Mail: wolf@di.epfl.ch | Phone: (++41 21)693 42 37
----------------------------------------------------------------------